
const { createWebAPIRequest } = require('../../util/util')
module.exports = [
  {
    /**
    * @api {get} /music/check/music [检验歌曲版权]
    * @apiGroup Music
    * @apiPermission none
    * @apiParam {Number} id  id
    * @apiParam {Number} [br=999000]
    */
    url: '/music/check/music',
    request: (req, res) => {
      const id = parseInt(req.query.id)
      const br = parseInt(req.query.br || 999000)
      const data = {
        ids: [id],
        br: br,
        csrf_token: ''
      }
      const cookie = req.get('Cookie') || ''

      createWebAPIRequest(
        'music.163.com',
        '/weapi/song/enhance/player/url',
        'POST',
        data,
        cookie,
        musicReq => {
          if (JSON.parse(musicReq).code === 200) {
            return res.send({ success: true, message: 'ok' })
          }
          return res.send({ success: false, message: '亲爱的,暂无版权' })
        },
        err => {
          res.status(500).send({err})
        }
      )
    }
  }
]
